import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:razer_one/app/main/extension/int_double_extension.dart';
import 'package:razer_one/app/main/view/main_btn.dart';
import 'package:razer_one/app/main/view/main_text.dart';
import 'package:razer_one/app/modules/me/me/me_controller.dart';

class MePage extends GetView<MeController> {
  const MePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MeController>(builder: (_) {
      return Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          title: const Text("我的"),
        ),
        body: ListView(
          children: [
            _buildHeadView(),
            _buildCell("个人信息", 0),
            _buildCell("组成员", 1),
            _buildCell("修改密码", 2),
            _buildLogoutBtn(),
          ],
        ),
      );
    });
  }

  _buildHeadView() {
    return Container(
      color: Colors.white,
      // height: 150.px,
      child: Column(
        children: [
          Row(
            children: [
              Container(
                padding: const EdgeInsets.only(top: 20, left: 20, bottom: 20),
                child: GestureDetector(
                  child: Row(children: [
                    Image.asset(
                        "lib/app/resource/images/commond/commond_head.png"),
                    sizeW(15),
                    MainText(
                      "名称: tiny",
                      fontSize: 16.px,
                    ),
                  ]),
                ),
              )
            ],
          ),
          sizeLine(Get.width, 10),
        ],
      ),
    );
  }

  _buildCell(String title, int index) {
    return GestureDetector(
      onTap: () {
        controller.jumpToPageByIndex(index);
      },
      child: Column(
        children: [
          Container(
            color: Colors.white,
            padding: const EdgeInsets.all(15),
            child: GestureDetector(
              behavior: HitTestBehavior.opaque,
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    MainText(title),
                    Image.asset(
                        "lib/app/resource/images/commond/commond_arrow.png")
                  ]),
            ),
          ),
          sizeLine(Get.width - 20, 0.5),
        ],
      ),
    );
  }

  _buildLogoutBtn() {
    return Container(
      padding: const EdgeInsets.only(top: 50, left: 15, right: 15),
      child: MainCommitBtn("退出登录", handle: controller.logoutBtnClick),
    );
  }
}
